Skip to main content

API - Send Your First OTP Call

Imagine this: You're building a secure and user-friendly application. You want to ensure your users can authenticate quickly and reliably, no matter where they are. The Betatel OTP Call API is here to help you make that happen! Follow these simple steps to integrate and send your first OTP call.

Step 1: Understand the Basics

The OTP Call API allows you to initiate an automated voice call that delivers a One-Time Password (OTP) message. This ensures secure communication between your application and the recipient.

OTP Call - Endpoint

https://api.betatel.com/api/v1/callgen/call/otp
  • Method: POST

Headers

Before you can make a request, your API call needs some essential details in the headers:

ParamValueDescription
Content-typeapplication/jsonSpecifies the payload format.
x-api-key{{x-api-key}API key for authorization.

Step 2: Build the Request

Now it’s time to prepare the payload for your request. This is like writing the script for the call. Here are the key parameters:

ParameterTypeRequiredDescription
calleestringYesThe phone number of the recipient (in international format).
callerstringYesThe phone number initiating the call (in international format).
testCallbooleanNoIndicates if the call is for testing purposes.
textstringYesThe OTP message to be delivered to the recipient.
languagestringYesThe language code for the message (e.g., en for English, zh for Chinese).
maxRingTimeintegerNoMaximum duration (in seconds) for ringing before the call is terminated.
maxBillTimeintegerNoMaximum billable duration (in seconds) for the call.

Here’s an example of a request body:

Example of body
{
"callee": "351913510668",
"caller": "381658345434",
"testCall":false,
"text":"Your auhtorization code is 345434",
"language":"zh",
"maxRingTime": 10,
"maxBillTime": 20
}
success

Test Before Going Live

Use the testCall parameter set to true to simulate the OTP call without actually delivering it. This ensures your integration is working as expected before live deployment.

Step 3: Make the Call

Now you’re ready to send your first OTP call! Choose your favorite programming language and use the following snippets to make the request.

Example - cURL
curl --location 'https://dev.api.betatel.com/api/v1/callgen/call/otp' \
--header 'x-api-key: Ng84v5PVF-NXcP9xPZAj8_9G8jtFQ5z9FVJd_cXlKzc' \
--header 'Content-Type: application/json' \
--data '{
"callee": "351913510668",
"caller": "381658345434",
"testCall":false,
"text":"Your auhtorization code is 345434",
"language":"zh",
"maxRingTime": 10,
"maxBillTime": 20
}'

Step 4: Check the Response

After making the call, the API will respond with a unique identifier (uuid) for your OTP call. Here’s what a successful response looks like:

  • Status Code: 200 OK

  • Content-Type: application/json

JSON Schema:

{
"uuid": "string"
}
note

Response Tracking

The uuid in the response acts as a unique identifier for the OTP call. Use it to track the status of the call or troubleshoot issues if necessary.

What’s Next?

🎉 Congratulations! You’ve successfully sent your first OTP call. Now, you can:

  • Integrate the API into your application workflows.
  • Customize the text, language, and timing to suit your users’ needs.
  • Explore other advanced features in the Betatel API documentation.

Your application is now one step closer to providing secure, reliable authentication with Betatel's OTP Call API. 🚀